/*==============================================================================
            Copyright (c) 2013 Moritz Hader, Marcel Schrder
            All Rights Reserved.

	@file  VertexManagementUnit.h

	@brief This header provides the class-definitions of the vertex-management.
	It provides functionallity to gather object-related data that are defined
	by vertex, color, normal and texture coordinates.
   
   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
==============================================================================*/

#ifndef _VERTEXMANAGEMENTUNIT_LIBRARY__
#define _VERTEXMANAGEMENTUNIT_LIBRARY__

#include <GLES2/gl2.h>

#include <egl/HeimdallMath.h>

//Forward declaration
class ShaderManagementUnit;

class VertexManagementUnit{
private:
	GLenum primitive; //Linear, Triangle, Cube etc.
	GLuint vertexCount; //Number of vertices

	//Attribute-Handles
	GLuint vertexAttribute;
	GLuint normalAttribute;
	GLuint colorAttribute;
	GLuint textureAttribute;

	//local-cache. Like this, we prevent the necessity to keep this list outside the Unit
	H3DVector* vertexArray;
		int vNum;
	H3DVector* normalArray;
		int nNum;
	H4DVector* colorArray;
		int cNum;

	//Lock
	bool isExecutable;

public:
	VertexManagementUnit(GLenum primType, GLuint vertices);
	~VertexManagementUnit();

	void AddVertexArray(H3DVector*);
		void AddVertex(H3DVector);
	void AddNormalArray(H3DVector*);
		void AddNormal(H3DVector);
	void AddColorArray(H4DVector*);
		void AddColor(H4DVector);

	void Finalize();

	void Draw();
};

#endif
